package com.qkl.xiatang.app.dto.wvp;

import com.qkl.xiatang.app.utils.ControlUtils;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

@Data
public class ControlCloudDTO {

    private static final Integer SPEED_DEFAULT = 60;

    private String channelId;

    private String command;

    private Integer horizonSpeed;

    private Integer verticalSpeed;

    private Integer zoomSpeed;

    public Map<String,String> toParams(){
        Map<String,String> map = new HashMap<>();
        map.put("channelId", StringUtils.trimToEmpty(channelId));
        map.put("command", StringUtils.trimToEmpty(command));
        ControlUtils.putParam(map,"horizonSpeed",toDefault(horizonSpeed));
        ControlUtils.putParam(map,"verticalSpeed",toDefault(verticalSpeed));
        ControlUtils.putParam(map,"zoomSpeed",toDefault(zoomSpeed));
        return map;
    }

    private static Integer toDefault(Integer speed){
        if(null == speed){
            return SPEED_DEFAULT;
        }
        return speed;
    }

    public static void main(String[] args) {
        ControlCloudDTO dto = new ControlCloudDTO();
        dto.setChannelId("31011500991310026322");
        dto.setCommand("left");
        dto.setHorizonSpeed(0);
        dto.setVerticalSpeed(0);
        dto.setZoomSpeed(0);
        System.out.println(com.alibaba.fastjson.JSON.toJSONString(dto));
    }

}
